package com.cloudpivot.receivales.contract.repository.erpcontract;

import com.cloudpivot.receivales.contract.entity.erpcontract.Inventory;
import com.cloudpivot.receivales.contract.entity.erpcontract.LastContractId;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

@Repository
public interface InventoryRepository extends JpaRepository<Inventory,String> {

    @Query(nativeQuery = true, value = "select cInvCode,cInvName,cInvCCode,cInvStd from Inventory where cInvCode = :cInvCode")
    Inventory getcInvCCode(@Param(value = "cInvCode") String cInvCode);

    /**
     * 获取erp产品对应单位中文
     * @param cInvCode
     * @return
     */
    @Query(nativeQuery = true, value = "select cu.cComUnitName from Inventory inv inner join ComputationUnit cu on cu.cComunitCode=inv.cComUnitCode where cInvCode=:cInvCode")
    String getInvUnit(@Param(value = "cInvCode") String cInvCode);

}
